package com.sccc.actions;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.sccc.biz.IadminManeger;
import com.sccc.bizImpl.AdminManeger;
import com.sccc.entity.User;

public class FindOneAllAction extends ActionSupport {
	private int id;
	

	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public String execute(int id) throws Exception {
		ActionContext ctx = ActionContext.getContext();//获取ActionContext对象
		HttpServletRequest request = ServletActionContext.getRequest();  //获取request对象
		AdminManeger adminmaneger = new AdminManeger();//所有方法的一个对象

		if(id!=0){
			
			
			User user2 = adminmaneger.findOneAll(id);
//			System.out.println(user.getUsername());
//			System.out.println(id);
//			System.out.println(user.getId());
			ctx.getSession().put("Username", user2.getUsername());
			request.setAttribute("Userpasswd", user2.getPasswd());
			request.setAttribute("Usersex", user2.getSex());
			request.setAttribute("Userjob", user2.getJob());
			request.setAttribute("Useremail", user2.getEmail());
			
			return SUCCESS;
			}
		
			return ERROR;
			
	}

}
